package com.example.smallmall.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.smallmall.entity.SpGoodsPics;
import com.example.smallmall.mapper.SpGoodsPicsMapper;
import com.example.smallmall.service.ISpGoodsPicsService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

/**
 * <p>
 * 商品-相册关联表 服务实现类
 * </p>
 *
 * @author WSGL
 * @since 2020-07-22
 */
@Service
public class SpGoodsPicsServiceImpl extends ServiceImpl<SpGoodsPicsMapper, SpGoodsPics> implements ISpGoodsPicsService {

    @Resource
    private SpGoodsPicsMapper spGoodsPicsMapper;
    @Override
    public Map<String,Object> selectById(int id) {
        Page<SpGoodsPics> page = new Page<>();
        IPage<SpGoodsPics> iPage = spGoodsPicsMapper.selectPage(page,new QueryWrapper<SpGoodsPics>().eq("goods_id", id));
        Map<String,Object> objectMap = new HashMap<>();
        objectMap.put("pics", iPage.getRecords());
        return objectMap;
    }
}
